package lab02.test06;

import java.util.Scanner;

public class Triangle {

    double a;
    double b;
    double c;

    boolean isTriangle;

    double perimeter;
    double area;

    public double getA() {
        return a;
    }

    public void setA(double a) {
        this.a = a;
    }

    public double getB() {
        return b;
    }

    public void setB(double b) {
        this.b = b;
    }

    public double getC() {
        return c;
    }

    public void setC(double c) {
        this.c = c;
    }


    //判断是否能构成三角形

    public boolean isTriangle() {
        if (a + b > c && a + c > b && b + c > a) {
            return true;
        } else
            return false;

    }

    //返回三角形的周长
    public double getPerimeter() {
        perimeter = a + b + c;
        return perimeter;
    }


    //返回三角形的面积
    public double getArea() {

        double s = (a + b + c) / 2;
        return Math.sqrt(s * (s - a) * (s - b) * (s - c));
    }

    //修改三个边
    public void alter() {
        System.out.println("请输入修改的信息：");

        System.out.println("边a:");
        Scanner sca = new Scanner(System.in);
        this.a = sca.nextDouble();

        System.out.println("边b:");
        Scanner scb = new Scanner(System.in);
        this.b = scb.nextDouble();

        System.out.println("边c:");
        Scanner scc = new Scanner(System.in);
        this.c = scc.nextDouble();

        System.out.println("修改成功！！");



    }


    @Override
    public String toString() {
        return "周长:" + getPerimeter() + "\n面积:" + getArea();
    }
}
